<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <script>
	
	/**
	* XDR for Chrome.
	* This is a background script engine, which should be requested via content script
	*
	*/
      function get(url, callback) {	
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function(data) {
          if (xhr.readyState == 4) {
            if (xhr.status == 200) {
              callback(data.srcElement.responseText);
            } else {
              callback(null);
            }
          }
        }
        // Note that any URL fetched here must be matched by a permission in
        // the manifest.json file!
        xhr.open('GET', url, true);
        xhr.send();
      };

      /**
       * Handles data sent via chrome.extension.sendRequest().
       * @param request Object Data sent in the request.
       * @param sender Object Origin of the request.
       * @param callback Function The method to call when the request completes.
       */
      function onRequest(request, sender, callback) {
        // Only supports the 'xget' action, although this could be
        // generalized into a more robust RPC system.
        if (request.action == 'xget') {
          get(request.url, callback);
        }
      };

      // Wire up the listener.
      chrome.extension.onRequest.addListener(onRequest);
	  
	  // get method should be called from the content script as follows:
	  // chrome.extension.sendRequest({'action' : 'xget', 'url':myUrl}, myCallback);
    </script>
  </body>
</html>